#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "movielistitemwidget.h"
#include "movielistitem.h"
#include <QMessageBox>

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
	ui->sidePanelSplitter->setStretchFactor(0, 0);	//Left side not expanding
	ui->sidePanelSplitter->setStretchFactor(1, 1);	//Right Side takes up all extra space

	MovieListItem *item;
	item = new MovieListItem(tr("Hello World"), ui->movieListWidget);
	new QListWidgetItem(QString("Standard QListWidgetItem 1"), ui->movieListWidget);

	ui->movieListWidget->setResizeMode(QListView::Adjust);
}

void MainWindow::closeEvent(QCloseEvent *event)
{
    QMessageBox msgBox;
    msgBox.setText("Are you sure you want to exit?");
    msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
    msgBox.setDefaultButton(QMessageBox::No);
    int result = msgBox.exec();

    if(result == QMessageBox::No)
        event->ignore();
    else
		event->accept();
}

MainWindow::~MainWindow()
{
    delete ui;
}
